<?php


	/*
	
	This function replaces the value 'YOURUSERID' within the 
	
	affiliate link with the one set in the admin area by the user.
	
	*/
	
	function ShopperAffiliateLink($link, $id=""){

	global $wpdb;
 
		if(get_option("display_linkcloak") =="yes" && strlen(get_option("tc_linkcloak")) > 5 && $id > 0){		
			return get_option("tc_linkcloak")."?link=".$id; 
		}
		
 		$pos = stripos($link, "affiliatefuture");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_2_ID"),$link);
			return $link.get_option("affiliates_2_TRACK");
		}

 		$pos = stripos($link, "linkshare");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_3_ID"),$link);
			return $link.get_option("affiliates_3_TRACK");
		}
		
 		$pos = stripos($link, "linksynergy");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_3_ID"),$link);
			return $link.get_option("affiliates_3_TRACK");
		}		

  		$pos = stripos($link, "regnow");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_4_ID"),$link);
			return $link.get_option("affiliates_4_TRACK");
		}

		$pos = stripos($link, "kqzyfj");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}

		$pos = stripos($link, "dpbolvw");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}
		
		$pos = stripos($link, "jdoqocy");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}
		
		$pos = stripos($link, "anrdoezrs");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}
		
		$pos = stripos($link, "tkqlhce");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}		
		$pos = stripos($link, "jdoqocy");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}

		$pos = stripos($link, "tkqlhce");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}

		$pos = stripos($link, "anrdoezrs");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_5_ID"),$link);
			return $link.get_option("affiliates_5_TRACK");
		}

  		$pos = stripos($link, "webgains");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_6_ID"),$link);
			return $link.get_option("affiliates_6_TRACK");
		}	

		$pos = stripos($link, "clickbank");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_7_ID"),$link);
			return $link.get_option("affiliates_7_TRACK");
		}

  		$pos = stripos($link, "tradedoubler");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_8_ID"),$link);
			return $link.get_option("affiliates_8_TRACK");
		}	

		$pos = stripos($link, "bridaluxe");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_9_ID"),$link);
			return $link.get_option("affiliates_9_TRACK");
		}
 
		$pos = stripos($link, "linkconnector");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_10_ID"),$link);
			return $link.get_option("affiliates_10_TRACK");
		}

		$pos = stripos($link, "netshops");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_11_ID"),$link);
			return $link.get_option("affiliates_11_TRACK");
		}

		$pos = stripos($link, "buy.at");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_12_ID"),$link);
			return $link.get_option("affiliates_12_TRACK");
		}

		$pos = stripos($link, "pepperjam");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_13_ID"),$link);
			return $link.get_option("affiliates_13_TRACK");
		}

		$pos = stripos($link, "pntrs");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_13_ID"),$link);
			return $link.get_option("affiliates_13_TRACK");
		}


		$pos = stripos($link, "google");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_14_ID"),$link);
			return $link.get_option("affiliates_14_TRACK");
		}

		$pos = stripos($link, "clickserve");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_14_ID"),$link);
			return $link.get_option("affiliates_14_TRACK");
		}

		$pos = stripos($link, "affiliatewindow");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_15_ID"),$link);
			return $link.get_option("affiliates_15_TRACK");
		}

		$pos = stripos($link, "awin1");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_15_ID"),$link);
			return $link.get_option("affiliates_15_TRACK");
		}

		$pos = stripos($link, "commissionmonster");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_16_ID"),$link);
			return $link.get_option("affiliates_16_TRACK");
		}

		$pos = stripos($link, "markethealth");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_17_ID"),$link);
			return $link.get_option("affiliates_17_TRACK");
		}

		$pos = stripos($link, "affilinet");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_18_ID"),$link);
			return $link.get_option("affiliates_18_TRACK");
		}

		$pos = stripos($link, "onenetworkdirect");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_19_ID"),$link);
			return $link.get_option("affiliates_19_TRACK");
		}

		$pos = stripos($link, "amazon");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_20_ID"),$link);
			return $link.get_option("affiliates_20_TRACK");
		}

		$pos = stripos($link, "shareasale");
		if ($pos !== false) {
			$link = str_replace('YOURUSERID',get_option("affiliates_1_ID"),$link);
			return $link.get_option("affiliates_1_TRACK");
		}		
 
	return $link;	
	
	}
	


?>